#include "btform.h"
#include "ui_btform.h"
#include <QDebug>
btForm::btForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::btForm)
{
    ui->setupUi(this);
    animationLine1 = new QPropertyAnimation(ui->line1,"geometry",this);
    animationLine1->setDuration(1500);
    animationLine1->setKeyValueAt(0,QRect(5,35,2,0));
    animationLine1->setKeyValueAt(0.5,QRect(5,5,2,30));
    animationLine1->setKeyValueAt(1,QRect(5,35,2,0));
    animationLine1->setLoopCount(-1);
    animationLine1->start();

    animationLine2 = new QPropertyAnimation(ui->line2,"geometry",this);
    animationLine2->setDuration(1600);
    animationLine2->setKeyValueAt(0,QRect(12,35,2,0));
    animationLine2->setKeyValueAt(0.5,QRect(12,5,2,30));
    animationLine2->setKeyValueAt(1,QRect(12,35,2,0));
    animationLine2->setLoopCount(-1);
    animationLine2->start();

    animationLine3 = new QPropertyAnimation(ui->line3,"geometry",this);
    animationLine3->setDuration(1700);
    animationLine3->setKeyValueAt(0,QRect(19,35,2,0));
    animationLine3->setKeyValueAt(0.5,QRect(19,5,2,30));
    animationLine3->setKeyValueAt(1,QRect(19,35,2,0));
    animationLine3->setLoopCount(-1);
    animationLine3->start();

    animationLine4 = new QPropertyAnimation(ui->line4,"geometry",this);
    animationLine4->setDuration(1800);
    animationLine4->setKeyValueAt(0,QRect(26,35,2,0));
    animationLine4->setKeyValueAt(0.5,QRect(26,5,2,30));
    animationLine4->setKeyValueAt(1,QRect(26,35,2,0));
    animationLine4->setLoopCount(-1);
    animationLine4->start();
}

btForm::~btForm()
{
    delete ui;
}

void btForm::seticon(QString btIcon, QString content, int mid)
{
    ui->btIcon->setPixmap(QPixmap(btIcon));
    ui->btText->setText(content);
    this->id = mid;
}

void btForm::clearBg()
{
    ui->btStyle->setStyleSheet("#btStyle:hover{background-color:#D8D8D8;}");
    ui->lineBox->setStyleSheet(".QLabel{background-color:rbg(255,255,255)}");
}

int btForm::getId()
{
    return id;
}

void btForm::mousePressEvent(QMouseEvent *event)
{
    // 告诉编译器不要触发警告
    (void)event;
    // 鼠标点击之后，背景变为绿色,设置动画可见
    ui->btStyle->setStyleSheet("#btStyle{ background:rgb(30,206,154);}*{color:#F6F6F6;}");
    ui->lineBox->setStyleSheet(".QLabel{background-color:rgb(37, 255, 164);}");
    //qDebug() <<"鼠标点击";
    emit click(this->id); // 发送⿏标点击信号
}
